# ICX Switch Configuration Script with Posh-SSH # This script is designed to extract IP Addresses from switches.txt, SSH into the switch # with the provided credentials (user1, userpassword), and execute the commands to move port 1/1/13 to VLAN 40. Then exit the session. # # Enter user credentials into the script $User = "user1" $PWord = ConvertTo-SecureString -String "userpassword" -AsPlainText -Force $Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord # Read hosts into the variable to perform on multiple hosts foreach($switchip in Get-Content .\switches.txt) { #Open the SSH session New-SSHSession -ComputerName $switchip -Credential ($Credential) -AcceptKey -Force -Verbose $SSHStream = New-SSHShellStream -Index 0 #Break to establish session sleep 10 # Write commands to the switch $SSHStream.WriteLine("config t") $SSHStream.WriteLine("vlan 40") $SSHStream.WriteLine("no untagged e 1/1/13") sleep 2 # End SSH session Remove-SSHSession -Index 0 }